package com.isoft.airportsystem.service.impl.Flight;

import com.isoft.airportsystem.entity.flight.BaggageInfo;
import com.isoft.airportsystem.mapper.Flight.BaggageMapper;
import com.isoft.airportsystem.service.flight.BaggageService;
import com.isoft.airportsystem.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class BaggageServiceImpl implements BaggageService {

    @Autowired
    private BaggageMapper baggageMapper;

    @Override
    public int getTotalBaggageCount() {
        return 0;
    }

    @Override
    public int getMishandledBaggageCount() {
        return 0;
    }

    @Override
    public Map<String, Integer> getBaggageStatusStats() {
        return Map.of();
    }

    @Override
    public List<Integer> getWeeklyBaggageCounts(List<String> dates) {
        return List.of();
    }

    @Override
    public List<BaggageInfo> getByFlightId(String flightId) {
        return baggageMapper.selectByFlightId(flightId);
    }

    @Override
    public BaggageInfo getByTag(String baggageTag) {
        return baggageMapper.selectByTag(baggageTag);
    }

    @Override
    public List<BaggageInfo> getByBeltNumber(String beltNumber) {
        return baggageMapper.selectByBeltNumber(beltNumber);
    }

    @Override
    public PageResult<BaggageInfo> queryBaggagePage(int pageNum, int pageSize, BaggageInfo baggage) {
        int offset = (pageNum - 1) * pageSize;
        List<BaggageInfo> list = baggageMapper.selectBaggagePage(offset, pageSize, baggage);
        int total = baggageMapper.countBaggages(baggage);
        return new PageResult<>(total, list);
    }

    @Override
    public boolean addBaggage(BaggageInfo baggage) {
        return baggageMapper.insertBaggage(baggage) > 0;
    }

    @Override
    public boolean updateBaggage(BaggageInfo baggage) {
        return baggageMapper.updateBaggage(baggage) > 0;
    }

    @Override
    public boolean deleteBaggage(String id) {
        return baggageMapper.deleteBaggage(id) > 0;
    }
}